package cn.echisan.springbootjwtdemo.voter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.FilterInvocation;

import java.util.Collection;

/**
 * <pre>
 * 用来对某个url下能否做哪些操作进行判断
 *
 * </pre>
 *
 * @author luoyunkai luoyunkai@kungeek.com
 * @version 1.00.00
 * @date 2020-03-30 星期一
 *
 * <pre>
 * 修改记录
 *    修改后版本:     修改人：  修改日期:     修改内容:
 * </pre>
 */

public class AbilityVote implements AccessDecisionVoter<FilterInvocation> {
    public static final Logger LOGGER = LoggerFactory.getLogger(AbilityVote.class);

    @Override
    public boolean supports(ConfigAttribute configAttribute) {
        LOGGER.debug(configAttribute.getAttribute());

        return true;
    }

    @Override
    public boolean supports(Class<?> aClass) {
        return true;
    }

    @Override
    public int vote(Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> collection) {
        filterInvocation.getRequestUrl();

        return ACCESS_ABSTAIN;
    }
}
